/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package riotlogic;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

/**
 *
 * @author HORUS793
 */
public class Player extends Character{
    private static Player instance = null;
 
    private Player(String name,int hp, int speed, Weapon wpn, int x, int y){
        super(name,hp,speed,wpn,x,y,'R');
        try{
                image = ImageIO.read(new File("Res/images.png"));
        } catch (IOException e){
                e.printStackTrace();
        }
    }

    public static Player getInstance(){
    	return Player.instance;
    }
    
    public static void makeInstance(String name,int hp, int speed, Weapon wpn, int x, int y){
    	Player.instance = new Player(name,hp,speed,wpn,x,y);
    } // This is a singleton.

    //Guess we don't actually need this method, unless we're thinking about
    //upgrading player's stats - Campillo
    public void setMaxHP(int newMaxHP){maxHP = newMaxHP;}

    public void setWeapon(Weapon newWpn){wpn = newWpn;}
    
    public void keyPressed(KeyEvent e){
    	int key = e.getKeyCode();
    	if(key == KeyEvent.VK_LEFT){
    		if(pnt.getX() > 0)	
    			pnt.setX(pnt.getX() - speed);
    		if(getFacing() == 'R')
    		{
    			shiftFacing();
    		}
    	}
    	if(key == KeyEvent.VK_RIGHT){
    		if(pnt.getX() < 900)		
    			pnt.setX(pnt.getX() + speed);
    		if(getFacing() == 'L')
    		{
    			shiftFacing();
    		}
    	}
    	
    	if(key == KeyEvent.VK_UP){
    		this.yAcceleration -= 20;
    		this.pnt.setY(pnt.getY()- 15);
    	}
    	//System.out.println("X,Y:"+pnt.getX()+","+pnt.getY() + "Facing:" + getFacing());
    }
}